#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 1005;
const int M = 105;
const int MOD = 1e9 + 7;

int n, m;
int x[M], y[M];
ll c[N][N];
ll dp[M][N];

void init(int n) {
  rep(i, 0, n) {
    c[i][0] = 1;
    rep(j, 1, i) c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % MOD;
  }
}
void solve() {
  cin >> m;
  rep(i, 1, m) cin >> x[i];
  rep(i, 1, m) cin >> y[i];
  n = accumulate(x + 1, x + m + 1, 0);
  init(n);
  int sum = 0;
  dp[0][0] = 1;
  rep(i, 1, m) {
    rep(j, 0, sum + x[i]) {
      int mn = max(0, j - x[i]), mx = min(sum, y[i] - x[i] + j);
      rep(k, mn, mx) {
        dp[i][j] = (dp[i][j] + dp[i - 1][k] * c[k + x[i]][j] % MOD) % MOD;
      }
    }
    sum += x[i];
    // rep(j, 0, sum) cout << dp[i][j] << " \n"[j == sum];
  }
  ll ans = dp[m][0];
  rep(i, 1, m) ans = ans * c[n][x[i]] % MOD, n -= x[i];
  cout << ans;
  return;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int t = 1;
  while (t--) solve();
  return 0;
}